home *** CD-ROM | disk | FTP | other *** search
/ CD Exchange / CD Exchange - Volume 1.iso / d.t.p / utils / propage / donsgenies / donsgenies.lha / Don'sGenies / ReplaceBoxesOnPages.pprx < prev    next >
Text File  |  1993-05-25  |  3KB  |  108 lines

  1. /*
  2. ReplaceBoxesOnPages
  3.  
  4. This Genie will replace each box at a particular position on a range of pages. You will be prompted to select the box which occurs at a position on the range of pages.
  5. The box you click on will replace all boxes in the page range which are in exactly the same position, as defined by the top left corner.
  6. Written by Don Cox  May '92. Not Public Domain. All rights reserved. 
  7. */
  8. cr = '0a'x
  9. pageopts = "OODDEEVENAALL"
  10. address command
  11. call SafeEndEdit.rexx()
  12. call ppm_AutoUpdate(0)
  13. counter = 0
  14.  
  15. signal on error
  16. signal on syntax
  17.  
  18.  
  19.  
  20. boxpos  = ppm_GetClickPosition("Click on box to be copied to each page")
  21. originalpage = ppm_CurrentPage()
  22. boxtop  = word(boxpos, 2)
  23. boxleft = word(boxpos, 1)
  24. box = ppm_BoxAtPosn(boxleft, boxtop)
  25. if box  = 0 then exit_msg()
  26.  
  27. if upper(word(ppm_GetBoxInfo(box), 1)) = "TEXT" & ppm_TextOverFlow(box) then
  28.     text = ppm_GetArticleText(box,1)
  29. else
  30.     text = ''
  31.  
  32.  
  33. docstart = ppm_DocFirstPage()
  34. docend = ppm_DocLastPage()
  35. pages = upper(ppm_GetForm("Enter range of pages", 20, "From:"docstart'0a'x "To:"docend'0a'x "ODD/EVEN/ALL"))
  36. if pages = '' then exit_msg()
  37.  
  38. parse var pages startpage '0a'x endpage '0a'x pageopt
  39.  
  40. if (startpage ~= '' & datatype(startpage) ~= NUM) | (endpage ~= '' & datatype(endpage) ~= NUM ) then exit_msg("Invalid Input")
  41.  
  42. increment = 1
  43.  
  44. /*
  45.  *  Check error conditions
  46.  */
  47. if startpage < docstart then exit_msg('Invalid Range')
  48. else if startpage > docend then exit_msg('Invalid Range')
  49. if endpage < docstart then exit_msg('Invalid Range')
  50. else if endpage > docend then exit_msg('Invalid Range')
  51. if endpage < startpage then exit_msg('Invalid Range')
  52.  
  53. if pageopt = 'ALL' | pageopt = 'A' then
  54. do
  55.     increment = 1
  56. end
  57. else if pageopt = 'EVEN' | pageopt = 'E' then
  58. do
  59.     increment   = 2
  60.     if (startpage // 2) then startpage = startpage + 1
  61. end
  62. else if pageopt = 'ODD' | pageopt = 'O' then
  63. do
  64.     increment   = 2
  65.     if ~(startpage // 2) then startpage = startpage + 1
  66. end
  67.  
  68. if startpage > endpage then
  69. do
  70.     temp    = startpage
  71.     startpage   = endpage
  72.     endpage = temp
  73. end
  74.  
  75.  
  76. do page = startpage to endpage by increment
  77. if page ~= originalpage then do
  78.     call ppm_ShowStatus("Working on page "page)
  79.     deadbox = ppm_BoxAtPosn(boxleft,boxtop,page)
  80.     if deadbox ~= 0 then do
  81.         newbox  = ppm_CloneBox(box, 0, 0)
  82.         call ppm_BoxChangePage(newbox, page)
  83.         if text ~= '' then do
  84.             call ppm_DeleteContents(newbox)
  85.             call ppm_TextIntoBox(newbox, text)
  86.         end
  87.  
  88.         gone = ppm_DeleteBox(deadbox)
  89.     end
  90. end 
  91.  
  92. end
  93.  
  94. exit_msg()
  95.  
  96. exit_msg: procedure
  97. do
  98.     parse arg message
  99.  
  100.     if message ~= '' then
  101.         call ppm_Inform(1,message,)
  102.  
  103.     call ppm_ClearStatus()
  104.     call ppm_AutoUpdate(1)
  105.     exit
  106. end
  107.  
  108.